#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "../game_func.h"
#include "../game_type.h"
#include "../game_api.h"
struct SelectRoleInfo {
	short RoleID;
	short x;
	short y;
	short Fix_x;
	short Fix_y;
	short Flag;
	int PicPtr;//图片指针
	int CMDPtr1;//没人选中时候的动作
	int CMDPtr2;//选中时候的动作
	int CMDPtr3;//应该是跳入八卦中心的动作
	int PalPtr;//颜色指针
};

struct PicInfo {
	int CMDPtr;
	int PicAxilPtr;
	int PicCollPtr;
	int PicCollDataPtr;
	int PicPtr;
	int PicBass;
	int Unk1;
};

const char CMDNiuMoWang[8]= {
	0x00,0x01,0x00,0x00,0xf0,0x01,0x00,0x00
};

const int PicNiuMoWang[7]= {
	0x1f8918,0x271ab4,0x271c70,0x271d4e,0x301350,0x5c9698,0x010430
};

//原版
// const struct SelectRoleInfo SelectRoleTbl[12]={
// {0x0000,0x00d3,0x00d8,0x000a,0xffe9,0x0000,0x1b1c1a,0x1b1afe,0x1b1b06,0x1b1b3a,0x2d3cde},//孙悟空
// {0x0001,0x007f,0x00d1,0x000e,0xffe3,0x0000,0x1beda6,0x1bec8a,0x1bec92,0x1becc6,0x2d5e66},//猪八戒
// {0x0002,0x003b,0x00cd,0x000d,0xffd8,0x0000,0x1cb930,0x1cb818,0x1cb820,0x1cb854,0x2d79ae},//沙悟净
// {0x0009,0x000e,0x00bb,0x0013,0xffc1,0x0000,0x1feb86,0x1fea5a,0x1fea62,0x1feaa6,0x2d0d3c},//老虎精
// {0x000a,0x0068,0x00a3,0x0005,0xffbb,0x0000,0x203e80,0x203d64,0x203d6c,0x203da0,0x2d0d7c},//银角
// {0x0006,0x00c2,0x0096,0xfff8,0xffb2,0x0000,0x1ee8b4,0x1ee788,0x1ee790,0x1ee7d4,0x2d0c7c},//蜘蛛精
// {0x0005,0x0107,0x0094,0xffff,0xffb4,0x0001,0x1e88a4,0x1e8788,0x1e8790,0x1e87c4,0x2d0c3c},//红孩儿
// {0x0007,0x0171,0x009e,0xffe7,0xffbf,0x0001,0x1f3a12,0x1f38e6,0x1f38ee,0x1f3932,0x2d0cbc},//鲤鱼精
// {0x0008,0x0191,0x00bb,0x000e,0xffc0,0x0001,0x1f8a44,0x1f8918,0x1f8920,0x1f8964,0x2d0cfc},//大象精
// {0x0004,0x0174,0x00cb,0x0004,0xffd9,0x0001,0x1e2802,0x1e26e6,0x1e26ee,0x1e2722,0x2daeca},//龙马
// {0x0003,0x0118,0x00d1,0x000f,0xffe2,0x0001,0x1d77c8,0x1d76ac,0x1d76b4,0x1d76e8,0x2d9686},//龙女
// {0x0000,0x00d3,0x00a8,0x000a,0xffe9,0x0000,0x1b1c1a,0x1b1afe,0x1b1b06,0x1b1b3a,0x2d3cde},//多写一个做测试用
// };

//改版
const struct SelectRoleInfo SelectRoleTbl[12]= {
	{0x0000,0x00d3,0x00d8,0x000a,0xffe9,0x0000,0x1b1c1a,0x1b1afe,0x1b1b06,0x1b1b3a,0x2d3cde},//孙悟空
	{0x0001,0x007f,0x00d1,0x000e,0xffe3,0x0000,0x1beda6,0x1bec8a,0x1bec92,0x1becc6,0x2d5e66},//猪八戒
	{0x0002,0x003b,0x00cd,0x000d,0xffd8,0x0000,0x1cb930,0x1cb818,0x1cb820,0x1cb854,0x2d79ae},//沙悟净
	{0x0009,0x000e,0x00bb,0x0013,0xffc1,0x0000,0x1feb86,0x1fea5a,0x1fea62,0x1feaa6,0x2d0d3c},//老虎精
	{0x000a,0x0068,0x00a3,0x0005,0xffbb,0x0000,0x203e80,0x203d64,0x203d6c,0x203da0,0x2d0d7c},//银角
	{0x0006,0x00c2,0x0096,0xfff8,0xffb2,0x0000,0x1ee8b4,0x1ee788,0x1ee790,0x1ee7d4,0x2d0c7c},//蜘蛛精
	{0x0005,0x0107,0x0094,0xffff,0xffb4,0x0001,0x1e88a4,0x1e8788,0x1e8790,0x1e87c4,0x2d0c3c},//红孩儿
	{0x0007,0x0171,0x009e,0xffe7,0xffbf,0x0001,0x1f3a12,0x1f38e6,0x1f38ee,0x1f3932,0x2d0cbc},//鲤鱼精
	{0x0008,0x0191,0x00bb,0x000e,0xffc0,0x0001,0x1f8a44,0x1f8918,0x1f8920,0x1f8964,0x2d0cfc},//大象精
	{0x0004,0x0174,0x00cb,0x0004,0xffd9,0x0001,0x1e2802,0x1e26e6,0x1e26ee,0x1e2722,0x2daeca},//龙马
	{0x0003,0x0118,0x00d1,0x000f,0xffe2,0x0001,0x1d77c8,0x1d76ac,0x1d76b4,0x1d76e8,0x2d9686},//龙女
	{0x0000,0x00f3,0x00d8,0x000a,0xffe9,0x0000,0x1b1c1a,0x1b1afe,0x1b1b06,0x1b1b3a,0x2d3cde},//多写一个做测试用
};


int SelectLeft(int Ptr1,int id) {
	int i;
	for(i=0; i<12; i++) {
		if(!DU16(Ptr1+id*2))
			return id;
		id += 1;
		if(id==12)
			id=0;
	}
	return 12;
}

int SelectRight(int Ptr1,int id) {
	int i;
	for(i=0; i<12; i++) {
		if(!DU16(Ptr1+id*2))
			return id;

		if(id==0)
			id=12;
		id += -1;
	}
	return 12;
}

void PageSelectRole(int PlayerID) {
	int i,j;
	short OBJ[12];
	short RoleState[12]= {0,0,0,0,0,0,0,0,0,0,0,0};
	int PlayerState[4];
	int PlayerPos[4];
	int PlayerOBJ[4];
	short OBJ_Bagua;
	int local_6;
	int iVar9;
	int iVar3;
	short local_92;
	short local_94;
	int iVar6;
	int iVar1;
	int TimeOBJ;
	int Time,Frame;
	int local_4e,local_4a,local_56,local_52,local_88;
	int NewPos;

	local_52 = 0;
	FUN_00187c94(0xf,0);
	FUN_00187ddc(0x14,0);
	FUN_001466d8(0x3179c4,5);//载入音乐
	FUN_0014671a(3);//播放音乐
	FUN_00106d7a(0,0xffffffff,0);
	//FUN_00110c02();
	//FUN_00110c04();//载入界面需要用到的色盘

	SetPal_00103f2a(1,0,0x314cb0);
	SetPal_00103f2a(2,0,0x2d388a);
	SetPal_00103f2a(2,1,0x2d38ca);
	SetPal_00103f2a(2,0x18,0x2b8d78);
	SetPal_00103f2a(2,0x19,0x2b8d78);
	SetPal_00103f2a(2,0x1a,0x2cf87c);
	SetPal_00103f2a(2,0x1b,0x2cd35c);


	local_88 = FUN_0010585c();
	FUN_001058ac(local_88,2,24,0,32,10,0x2b8d78,0x2b8db8);
	FUN_0010cc7c(0,10,0x48,26,0x18b3dc,1,0);//画八卦边上的图
	OBJ_Bagua = FUN_0010cc7c(0,10,0x49,26,0x18b3dc,1,5);//画八卦中心图
	FUN_0012f0f2(0,0,0,0x3f,27,0,0,0);//画背景的云
	switch(FUN_0014a996()) { //这里根据游戏区域来选择图片
	case 3:
		local_6 = 50;
		break;
	case 1:
		local_6 = 48;
		break;
	default:
		local_6 = 46;
		break;
	}
	FUN_00110142(0xe0,31,0,local_6 + 1,0,0,32000,0);//画选择角色的文字


	for(i=0; i<12; i++) {//画11个人物
		SetPalGray_0010531e(2,2+i,SelectRoleTbl[i].PalPtr,0x7fff);//把人物颜色变灰色
		OBJ[i] = FUN_0011bb58();
		SetOBJ_0011bd7a(OBJ[i],SelectRoleTbl[i].PicPtr,SelectRoleTbl[i].x,SelectRoleTbl[i].y,0,SelectRoleTbl[i].Flag);
		SetOBJCMD_0011df04(OBJ[i],SelectRoleTbl[i].CMDPtr1);//让角色图片执行动作1
		SetOBJPal_0011c1ee(OBJ[i],2+i);//11个人物占用13-23号色盘
	}





	FUN_001061a6();
	FadeIn_00104c66(0);
	SetOBJCMD_0011df04(OBJ_Bagua,0x18b3e4);//让八卦中心转起来

	for(i=0; i<4; i++) {
		PlayerState[i]=0;
		PlayerOBJ[i]=0xffffffff;
		PlayerPos[i]=0;
	}
	FUN_001183b0(PlayerID);//画1P的标志
	PlayerState[PlayerID] = 1;
	PlayerPos[PlayerID] = 0;
	RoleState[0] = 1;
	PlayerOBJ[PlayerID] = FUN_00110ce4(PlayerID,0);
	local_4a = 0;
	local_4e = 1;
	api_wpal(2,SelectRoleTbl[0].PalPtr);//让1P当前选中的人变亮
	//SetOBJPal_0011c1ee(OBJ[0],2);

	TimeOBJ=FUN_00110142(0x1a4,0x28,0,0x3d,1,0,32000,0);//画倒计时的数字

	Time = 9;
	Frame = 80;

	for(Time=8; Time>-1; Time--) {
		for(Frame=80; Frame>-1; Frame--) {
			if(!Frame && !Time) { //如果时间到了就让正在选人的玩家直接选人了
				FUN_0011e1ac(TimeOBJ,0x34 + Time);//让倒计时数字-1
				PlaySound_00187b7e(0,6,0xff,0);
				for(i=0; i<4; i++) {
					if(PlayerState[i]==1) {
						local_4a += 1;//已选人数+1
						PlayerState[i] = 2;//玩家状态变成2
						FUN_0011adf0(0x80cd34+i*0x286,SelectRoleTbl[PlayerPos[i]].RoleID);//根据角色ID初始化玩家数据
						SetOBJCMD_0011df04(OBJ[PlayerPos[i]],SelectRoleTbl[PlayerPos[i]].CMDPtr3);//切换动作
						FUN_0011dfec(PlayerOBJ[i],SelectRoleTbl[PlayerPos[i]].x+SelectRoleTbl[PlayerPos[i]].Fix_x,SelectRoleTbl[PlayerPos[i]].y+SelectRoleTbl[PlayerPos[i]].Fix_y);//移动光标
						FUN_0011df3c(PlayerOBJ[i],1,30000);
						SetOBJCMD_0011df04(PlayerOBJ[i],0x18b478);
						SetOBJPal_0011c1ee(PlayerOBJ[i],25);
					}
				}
				for(i=0; i<60; i++) { //让选中角色跳入八卦中心
					for(j=0; j<4; j++) {
						iVar3 = FUN_0011dd64(OBJ[PlayerPos[j]]);
						if(PlayerState[j]==2 && DU8(iVar3) == 2) {
							local_92 = 0;
							local_94 = 0;
							iVar6 =FUN_00110ddc(iVar3,0xe0,0xb4,3,2,&local_92,&local_94);
							if(!iVar6) {
								DU16(iVar3 + 0x14) += local_92;
								DU16(iVar3 + 0x16) += local_94;
								FUN_00109752(DU8(iVar3+0x42),(iVar6&0xffff0000)|(DU16(iVar3+0x73*2)+DU16(iVar3+0x16)));
							}
						}
					}
					ScreenUpdate_00109c28();
				}
				FUN_00105b8c(local_88);//
				FUN_00104c4c(0);
				FUN_00103078();
				FUN_0011bb38();
				FUN_00109460();
				return;
			}
			/*检测1-4P玩家按键*/
			for(i=0; i<4; i++) {
				switch(PlayerState[i]) { //根据玩家状态设置控制权
				case 0://状态0 未加入游戏
					if(ChkKeyPress_00101e0c(i*8+1) && FUN_001182ee(i) ) { //按了开始键
						FUN_001183b0(i);
						PlayerState[i]=1;//这里把玩家状态设置到1，之后就不会检测开始键了
						PlayerPos[i] = SelectLeft(RoleState,0);//这里传一个值进去，给角色分配一个不冲突的pos
						RoleState[PlayerPos[i]] = 1; //这里让角色互斥
						PlayerOBJ[i] = FUN_00110ce4(i,PlayerPos[i]);//画一个新光标在所选角色上
						//SetOBJPal_0011c1ee(OBJ[PlayerPos[i]],2+PlayerPos[i]);//把新选择的角色上色
						api_wpal(2+PlayerPos[i],SelectRoleTbl[PlayerPos[i]].PalPtr);
						local_4e += 1;//玩家数+1
						Time = 9;//重置倒计时
						Frame = 80;
					}
					break;
				case 1://状态1 正在选人
					if(!ChkKeyPress_00101e0c(i*8+6)) { //这里判断是没有按A键
						NewPos = -1;
						if(ChkKeyPress_00101e0c(i*8+4)) { //按了左键
							NewPos = SelectLeft(RoleState,PlayerPos[i]);
						}
						if(ChkKeyPress_00101e0c(i*8+5)) { //按了右键
							NewPos = SelectRight(RoleState,PlayerPos[i]);
						}
						if(NewPos!=-1) {
							PlaySound_00187b7e(0,0x9e,0xe6,0);//播放切换人物的音效
							//SetOBJPal_0011c1ee(OBJ[PlayerPos[i]],13+PlayerPos[i]);//把之前的人物变灰色
							//api_print(0,0,2,3,0,"%d %d",PlayerPos[i],NewPos);
							SetPalGray_0010531e(2,2+PlayerPos[i],SelectRoleTbl[PlayerPos[i]].PalPtr,0x7fff);//把旧人物颜色变灰色
							//api_wpal(2+PlayerPos[i],SelectRoleTbl[PlayerPos[i]].PalPtr);
							api_wpal(2+NewPos,SelectRoleTbl[NewPos].PalPtr);//新人物颜色变回原来的颜色

							//api_delay(1);
							RoleState[PlayerPos[i]] = 0;
							RoleState[NewPos] = 1;
							PlayerPos[i] = NewPos;
							//SetOBJPal_0011c1ee(OBJ[PlayerPos[i]],2+PlayerPos[i]);//让新人物使用标准色盘
							//SetOBJPal_0011c1ee(OBJ[PlayerPos[i]],2+PlayerPos[i]);//把新位置变亮
							//api_wpal(2+PlayerPos[i],SelectRoleTbl[PlayerPos[i]].PalPtr);
							FUN_0011dfec(PlayerOBJ[i],SelectRoleTbl[PlayerPos[i]].x+SelectRoleTbl[PlayerPos[i]].Fix_x,SelectRoleTbl[PlayerPos[i]].y+SelectRoleTbl[PlayerPos[i]].Fix_y);//移动光标
							FUN_0011df3c(PlayerOBJ[i],1,30000);
						}
					} else { //这个就是按了A键选人了
						local_4a += 1;//已选人数+1
						PlayerState[i] = 2;//玩家状态变成2
						FUN_0011adf0(0x80cd34+i*0x286,SelectRoleTbl[PlayerPos[i]].RoleID);//根据角色ID初始化玩家数据
						SetOBJCMD_0011df04(OBJ[PlayerPos[i]],SelectRoleTbl[PlayerPos[i]].CMDPtr3);//切换动作
						FUN_0011dfec(PlayerOBJ[i],SelectRoleTbl[PlayerPos[i]].x+SelectRoleTbl[PlayerPos[i]].Fix_x,SelectRoleTbl[PlayerPos[i]].y+SelectRoleTbl[PlayerPos[i]].Fix_y);//移动光标
						FUN_0011df3c(PlayerOBJ[i],1,30000);
						SetOBJCMD_0011df04(PlayerOBJ[i],0x18b478);
						SetOBJPal_0011c1ee(PlayerOBJ[i],25);
						if(FUN_0010cbce()) { //这里不知道是干啥
							local_52 = 1;
							break;
						}
					}
					break;


				}


			}
			if((local_4a == local_4e)) { //这里判断玩家数是否和已选人数相等，如果相等，就开始游戏了
				for(i=0; i<60; i++) { //让选中角色跳入八卦中心
					for(j=0; j<4; j++) {
						iVar3 = FUN_0011dd64(OBJ[PlayerPos[j]]);
						if(PlayerState[j]==2 && DU8(iVar3) == 2) {
							local_92 = 0;
							local_94 = 0;
							iVar6 =FUN_00110ddc(iVar3,0xe0,0xb4,3,2,&local_92,&local_94);
							if(!iVar6) {
								DU16(iVar3 + 0x14) += local_92;
								DU16(iVar3 + 0x16) += local_94;
								FUN_00109752(DU8(iVar3+0x42),(iVar6&0xffff0000)|(DU16(iVar3+0x73*2)+DU16(iVar3+0x16)));
							}
						}
					}
					ScreenUpdate_00109c28();
				}
				FUN_00105b8c(local_88);//
				FUN_00104c4c(0);
				FUN_00103078();
				FUN_0011bb38();
				FUN_00109460();
				return;
			}
			for(j=0; j<4; j++) {
				iVar3 = FUN_0011dd64(OBJ[PlayerPos[j]]);
				if(PlayerState[j]==2 && DU8(iVar3) == 2) {
					local_92 = 0;
					local_94 = 0;
					iVar6 =FUN_00110ddc(iVar3,0xe0,0xb4,3,2,&local_92,&local_94);
					if(!iVar6) {
						DU16(iVar3 + 0x14) += local_92;
						DU16(iVar3 + 0x16) += local_94;
						FUN_00109752(DU8(iVar3+0x42),(iVar6&0xffff0000)|(DU16(iVar3+0x73*2)+DU16(iVar3+0x16)));
					}
				}
			}






			api_delay(1);
		}
		FUN_0011e1ac(TimeOBJ,0x34 + Time);//让倒计时数字-1

		if(!Time)
			PlaySound_00187b7e(0,6,0xff,0);
		else
			PlaySound_00187b7e(0,5,0xff,0);
	}









	api_delay(0);

























	// if(local_52) {
	// for(i=0; i<60; i++) { //让选中角色跳入八卦中心
	// for(j=0; j<4; j++) {
	// iVar3 = FUN_0011dd64(OBJ[PlayerArr3[j]]);
	// if(PlayerArr1[j]==2 && DU8(iVar3) == 2) {
	// local_92 = 0;
	// local_94 = 0;
	// iVar6 =FUN_00110ddc(iVar3,0xe0,0xb4,3,2,&local_92,&local_94);
	// if(!iVar6) {
	// DU16(iVar3 + 0x14) += local_92;
	// DU16(iVar3 + 0x16) += local_94;
	// FUN_00109752(DU8(iVar3+0x42),(iVar6&0xffff0000)|(DU16(iVar3+0x73*2)+DU16(iVar3+0x16)));
	// }
	// }
	// }
	// ScreenUpdate_00109c28();
	// }
	// FUN_00105b8c(local_88);//这里应该是释放定时器
	// FUN_00104c4c(0);
	// FUN_00103078();
	// FUN_0011bb38();
	// FUN_00109460();
	// return;
	// }

	// for(Time=9; Time>-1; Time--) {
	// for(Frame=80; Frame>-1; Frame--) {//一秒80帧
	// ScreenUpdate_00109c28();
	// /*下面是控制选人光标*/
	// for(i=0; i<4; i++) {
	// if(PlayerArr1[i]!=2) {
	// if(!PlayerArr1[i] && ChkKeyPress_00101e0c(DU8(0x193458+i*8)) && FUN_001182ee(i)) { //有新玩家加入

	// FUN_001183b0(i);
	// PlayerArr1[i]=1;
	// PlayerArr3[i] = FUN_00110d7e(&PAL,0);
	// PAL[PlayerArr3[i]] = 1;
	// PlayerArr2[i] = FUN_00110ce4(i,PlayerArr3[i]);
	// SetOBJPal_0011c1ee(OBJ[PlayerArr3[i]],PlayerArr3[i]+2);
	// local_4e += 1;
	// Time = 9;
	// Frame = 80;
	// }
	// if(PlayerArr1[i]==1) {
	// if(ChkKeyPress_00101e0c(DU8(0x193458+i*8+5))) { //按了B键
	// local_56 = -1;
	// if(ChkKeyPress_00101e0c(DU8(0x193458+i*8+3)))
	// local_56 = FUN_00110d7e(&PAL,PlayerArr3[i]);
	// }
	// if(ChkKeyPress_00101e0c(DU8(0x193458+i*8+4)))//按了A键
	// local_56 = FUN_00110dae(&PAL,PlayerArr3[i]);
	// if(local_56 != -1) {
	// PlaySound_00187b7e(0,0x9e,0xe6,0);
	// SetOBJPal_0011c1ee(OBJ[PlayerArr2[i]],13+PlayerArr2[i]);
	// PAL[PlayerArr3[i]] = 0;
	// PAL[local_56] = 1;
	// PlayerArr3[i] = local_56;
	// SetOBJPal_0011c1ee(OBJ[PlayerArr3[i]],PlayerArr3[i]+2);
	// FUN_0011dfec(PlayerArr2[i],DU16( 0x18b27c + PlayerArr3[i]*0x20 +2)+DU16(0x18b27c+PlayerArr3[i]*0x20+6),
	// DU16(0x18b27c+PlayerArr3[i]*0x20+4),DU16(0x18b27c+PlayerArr3[i]*0x20+8));
	// FUN_0011df3c(PlayerArr2[i],1,30000);
	// } else {
	// local_4a += 1;
	// PlayerArr1[i] = 2;
	// FUN_0011adf0(0x80cd34+i*286,DU16(0x18b27c+PlayerArr3[i]*0x20));
	// SetOBJCMD_0011df04(OBJ[PlayerArr3[i]],PU32(0x18b294)[PlayerArr3[i]*8]);
	// FUN_0011dfec(PlayerArr2[i],DU16( 0x18b27c + PlayerArr3[i]*0x20 +2)+DU16(0x18b27c+PlayerArr3[i]*0x20+6),
	// DU16(0x18b27c+PlayerArr3[i]*0x20+4),DU16(0x18b27c+PlayerArr3[i]*0x20+8));
	// FUN_0011df3c(PlayerArr2[i],1,30000);
	// SetOBJCMD_0011df04(PlayerArr2[i],0x18b478);
	// SetOBJPal_0011c1ee(PlayerArr2[i],0x19);
	// if(FUN_0010cbce()) {
	// local_52 = 1;
	// break;
	// }

	// }


	// }


	// }



	// }

	// if(local_4a == local_4e) {
	// for(i=0; i<60; i++) { //让选中角色跳入八卦中心
	// for(j=0; j<4; j++) {
	// iVar3 = FUN_0011dd64(OBJ[PlayerArr3[j]]);
	// if(PlayerArr1[j]==2 && DU8(iVar3) == 2) {
	// local_92 = 0;
	// local_94 = 0;
	// iVar6 =FUN_00110ddc(iVar3,0xe0,0xb4,3,2,&local_92,&local_94);
	// if(!iVar6) {
	// DU16(iVar3 + 0x14) += local_92;
	// DU16(iVar3 + 0x16) += local_94;
	// FUN_00109752(DU8(iVar3+0x42),(iVar6&0xffff0000)|(DU16(iVar3+0x73*2)+DU16(iVar3+0x16)));
	// }
	// }
	// }
	// ScreenUpdate_00109c28();
	// }
	// FUN_00105b8c(local_88);//这里应该是释放定时器
	// FUN_00104c4c(0);
	// FUN_00103078();
	// FUN_0011bb38();
	// FUN_00109460();
	// return;
	// }

	// for(i=0; i<4; i++) {
	// iVar3 = FUN_0011dd64(OBJ[PlayerArr3[i]]);
	// if(PlayerArr1[i]==2 && iVar3 == 2) {
	// iVar6 = FUN_00110ddc(iVar3,0xe0,0xb4,3,2,&local_92,&local_94);
	// if(!iVar6) {
	// DU16(iVar3 + 0x14) += local_92;
	// DU16(iVar3 + 0x16) += local_94;
	// FUN_00109752(DU8(iVar3+0x42),(iVar6&0xffff0000)|(DU16(iVar3+0x73*2)+DU16(iVar3+0x16)));
	// }
	// }
	// }







	// if(!Time && !Frame) {
	// for(i=0; i<4; i++) {
	// if(PlayerArr1[i]==1) {
	// iVar1 = PlayerArr3[i] * 0x20;
	// PlayerArr1[i] = 2;
	// FUN_0011adf0(0x80cd34+i*0x286,0x18b27c+iVar1);//0x80cd34是PlayerMem的基址4*0x286大小
	// SetOBJCMD_0011df04(OBJ[PlayerArr3[i]],PU32(0x18b294)[PlayerArr3[i]*8]);
	// FUN_0011dfec(PlayerArr2[i],DU16( 0x18b27c + PlayerArr3[i]*0x20 +2)+DU16(0x18b27c+PlayerArr3[i]*0x20+6),
	// DU16(0x18b27c+PlayerArr3[i]*0x20+4),DU16(0x18b27c+PlayerArr3[i]*0x20+8));
	// FUN_0011df3c(PlayerArr2[i],1,30000);
	// SetOBJCMD_0011df04(PlayerArr2[i],0x18b478);
	// SetOBJPal_0011c1ee(PlayerArr2[i],0x19);
	// }
	// }


	// for(i=0; i<60; i++) { //让选中角色跳入八卦中心
	// for(j=0; j<4; j++) {
	// iVar3 = FUN_0011dd64(OBJ[PlayerArr3[j]]);
	// if(PlayerArr1[j]==2 && DU8(iVar3) == 2) {
	// local_92 = 0;
	// local_94 = 0;
	// iVar6 =FUN_00110ddc(iVar3,0xe0,0xb4,3,2,&local_92,&local_94);
	// if(!iVar6) {
	// DU16(iVar3 + 0x14) += local_92;
	// DU16(iVar3 + 0x16) += local_94;
	// FUN_00109752(DU8(iVar3+0x42),(iVar6&0xffff0000)|(DU16(iVar3+0x73*2)+DU16(iVar3+0x16)));
	// }
	// }
	// }
	// ScreenUpdate_00109c28();
	// }
	// FUN_00105b8c(local_88);//这里应该是释放定时器
	// FUN_00104c4c(0);
	// FUN_00103078();
	// FUN_0011bb38();
	// FUN_00109460();
	// return;
	// }







	// ScreenUpdate_00109c28();
	// }

	// FUN_0011e1ac(TimeOBJ,0x34 + Time-1);
	// if(!Time)
	// PlaySound_00187b7e(0,6,0xff,0);
	// else
	// PlaySound_00187b7e(0,5,0xff,0);
	// }
















	return;
	//api_delay(0);
}